public class Student {
    private long id;
    private String name;
    private byte age;
    private char sex;
    private String className;
    private static long idCount = 1L;

    public Student() {
        this("", (byte)0, 'M', "");
    }

    public Student(String name) {
        this(name, (byte)0, 'M', "");
    }

    public Student(String name, byte age) {
        this(name, age, 'M', "");
    }

    public Student(String name, byte age, char sex) {
        this(name, age, sex, "");
    }

    public Student(String name, byte age, char sex, String cName) {
        set(name, age, sex, cName);
        id = idCount++;
    }

    public Student set(String name) {
        this.name = name;
        return this;
    }

    public Student set(byte age) {
        this.age = age;
        return this;
    }

    public Student set(char sex) {
        this.sex = sex;
        return this;
    }

    public Student setClass(String cName) {
        this.className = cName;
        return this;
    }

    public Student set(String key, Object val) {
        if (key.equals("name"))
            name = (String)val;
        else if (key.equals("age"))
            age = (byte)val;
        else if (key.equals("sex"))
            sex = (char)val;
        else if (key.equals("classname"))
            className = (String)val;

        return this;
    }

    public Student set(String name, byte age, char sex, String cName) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.className = cName;
        return this;
    }

    public String get(String key) {
        if (key.equals("name"))
            return name;
        else if (key.equals("age"))
            return "".valueOf(age);
        else if (key.equals("sex"))
            return "".valueOf(sex);
        else if (key.equals("classname"))
            return className;
        else if (key.equals("id"))
            return "".valueOf(id);
        return "";
    }

    public long getId() {
        return id;
    }

    public Student show(String prompt) {
        System.out.printf("%s%10d %8s %c %2d %-12s\n",
                            prompt, id, name, sex, age, className);
        return this;
    }

    public boolean equals(Object obj) {
        // System.out.printf("Student equals!\n");
        if (obj instanceof Student) {
            return (((Student)obj).id == id) ? true : false;
        } else if (obj instanceof String) {
            return name.equals((String)obj);
        } else if (obj instanceof Byte) {
            return (age == (byte)obj) ? true : false;
        } else if (obj instanceof Character) {
            return (sex == (char)obj) ? true : false;
        }

        return false;
    }
}
